*! 绘制双变量动态环形图
*! 程振兴 2018年7月15日
*! ddc 甲方 12.8 乙方 78.5
cap prog drop ddc
prog define ddc
	version 14.0
	syntax anything [, HTMLname(string)]
	tokenize `anything'
	local text1 = "`1'"
	local text2 = "`3'"
	local num1 = "`2'"
	local num2 = "`4'"
	qui{
		fw, s h(`htmlname')
		jscopy
		lib, b
		fw `"var manValue = `num1', womanValue = `num2', total = manValue + womanValue;"'
		fw `"option = {"'
		fw `"    baseOption: {"'
		fw `"        timeline: {"'
		fw `"            show: false,"'
		fw `"            type: 'slider',"'
		fw `"            axisType: 'category',"'
		fw `"            bottom: '10',"'
		fw `"            currentIndex: 0,//0 时表示当前选中项为 timeline.data[0]（即使用 options[0]"'
		fw `"            autoPlay: true,//是否自动播放"'
		fw `"            loop: true,"'
		fw `"            realtime: true,//拖动圆点的时候，是否实时更新视图。"'
		fw `"            controlPosition: 'left',"'
		fw `"            label: {"'
		fw `"                normal: {"'
		fw `"                    color: '#2998ff',"'
		fw `"                },"'
		fw `"            },"'
		fw `"            itemStyle: {"'
		fw `"                normal: {"'
		fw `"                    color: '#fff',"'
		fw `"                    borderColor: '#2998ff',"'
		fw `"                    borderWidth: 2,"'
		fw `"                }"'
		fw `"            },"'
		fw `"            checkpointStyle: {//『当前项』（checkpoint）的图形样式"'
		fw `"                color: 'rgb(215, 0, 0)',"'
		fw `"            },"'
		fw `"            lineStyle: {"'
		fw `"                show: true,//false 不显示轴线"'
		fw `"                color: '#2998ff',"'
		fw `"            },"'
		fw `"            controlStyle: {//控制按钮的样式"'
		fw `"                show: false,"'
		fw `"                showPrevBtn: false,"'
		fw `"                showNextBtn: false,"'
		fw `"                itemGap: 50,"'
		fw `"                itemSize: 36,"'
		fw `"                normal: {"'
		fw `"                    color: 'rgb(215, 0, 0)',"'
		fw `"                    borderColor:'rgb(215, 0, 0)',"'
		fw `"                },"'
		fw `"                emphasis: {"'
		fw `"                    color: 'rgb(215, 0, 0)',"'
		fw `"                    borderColor:'rgb(215, 0, 0)',"'
		fw `"                },"'
		fw `"            },"'
		fw `"            data: ['男','女'],"'
		fw `"        },"'
		fw `"        title: {"'
		fw `"        text: '',"'
		fw `"        x: '50%',"'
		fw `"        y: '45%',"'
		fw `"        textAlign: "center","'
		fw `"        textStyle: {"'
		fw `"            fontWeight: 'normal',"'
		fw `"            fontSize: 24"'
		fw `"        },"'
		fw `"        subtextStyle: {"'
		fw `"            fontWeight: 'bold',"'
		fw `"            fontSize: 32,"'
		fw `"            color: '#3ea1ff'"'
		fw `"        }"'
		fw `"    },"'
		fw `"        tooltip: { //提示框组件"'
		fw `"            trigger: 'axis',"'
		fw `"            formatter: '{b}<br />{a0}: {c0}<br />{a1}: {c1}',"'
		fw `"            axisPointer: {"'
		fw `"                type: 'shadow',"'
		fw `"                label: {"'
		fw `"                    backgroundColor: '#6a7985'"'
		fw `"                }"'
		fw `"            },"'
		fw `"            textStyle: {"'
		fw `"                color: '#fff',"'
		fw `"                fontStyle: 'normal',"'
		fw `"                fontFamily: '微软雅黑',"'
		fw `"                fontSize: 12,"'
		fw `"            }"'
		fw `"        },"'
		fw `"        grid: {"'
		fw `"            left: 10,"'
		fw `"            right: 35,"'
		fw `"            bottom: 70,"'
		fw `"            top:60,"'
		fw `"            containLabel: true,"'
		fw `"        },"'
		fw `"        legend: {//图例组件，颜色和名字"'
		fw `"            left: 0,"'
		fw `"            top:0,"'
		fw `"            itemGap: 16,"'
		fw `"            itemWidth: 20,"'
		fw `"            itemHeight: 14,"'
		fw `"            data:[{"'
		fw `"                name:'2017-08-05 至 2017-08-05',"'
		fw `"                icon:'rect', "'
		fw `"            },"'
		fw `"            {"'
		fw `"                name:'2017-08-06 至 2017-08-06',"'
		fw `"                icon:'rect', "'
		fw `"            }],"'
		fw `"            textStyle: {"'
		fw `"                color: '#a8aab0',"'
		fw `"                fontStyle: 'normal',"'
		fw `"                fontFamily: '微软雅黑',"'
		fw `"                fontSize: 12,            "'
		fw `"            }"'
		fw `"        },"'
		fw `"        series: [{"'
		fw `"            name: '比例圆',"'
		fw `"            type: 'pie',"'
		fw `"            radius: ['50%', '70%'],"'
		fw `"            startAngle: 225,"'
		fw `"            color: [new echarts.graphic.LinearGradient(0, 0, 0, 1, [{"'
		fw `"                offset: 0,"'
		fw `"                color: '#00a2ff'"'
		fw `"            }, {"'
		fw `"                offset: 1,"'
		fw `"                color: '#70ffac'"'
		fw `"            }]), "transparent"],"'
		fw `"            hoverAnimation: false,"'
		fw `"            legendHoverLink: false,"'
		fw `"            itemStyle: {"'
		fw `"                normal: {"'
		fw `"                    borderColor: "transparent","'
		fw `"                    borderWidth: "20""'
		fw `"                },"'
		fw `"                emphasis: {"'
		fw `"                    borderColor: "transparent","'
		fw `"                    borderWidth: "20""'
		fw `"                }"'
		fw `"            },"'
		fw `"            z: 10,"'
		fw `"            labelLine: {"'
		fw `"                normal: {"'
		fw `"                    show: false"'
		fw `"                }"'
		fw `"            }"'
		fw `"        }, {"'
		fw `"            name: '底层圆',"'
		fw `"            type: 'pie',"'
		fw `"            radius: ['50%', '70%'],"'
		fw `"            startAngle: 225,"'
		fw `"            color: ["#c2f5e1", "transparent"],"'
		fw `"            labelLine: {"'
		fw `"                normal: {"'
		fw `"                    show: false"'
		fw `"                }"'
		fw `"            },"'
		fw `"            data: [{value: 75}, {value: 25}]"'
		fw `"        }"'
		fw `"        ]"'
		fw `"    },"'
		fw `"    options: ["'
		fw `"        {"'
		fw `"            title:{"'
		fw `"                text:'`text1'',"'
		fw `"                subtext : manValue + '%',"'
		fw `"            },"'
		fw `"            "'
		fw `"            series: ["'
		fw `"                {data: [{value: manValue * 0.75}, {value: total - manValue*0.75}]},"'
		fw `"                "'
		fw `"            ]"'
		fw `"        },"'
		fw `"        {"'
		fw `"            title:{"'
		fw `"                text:'`text2'',"'
		fw `"                subtext : womanValue + '%',"'
		fw `"            },"'
		fw `"            series: ["'
		fw `"                {data: [{value: womanValue * 0.75}, {value: total - womanValue*0.75}]},"'
		fw `"                "'
		fw `"            ]"'
		fw `"        }"'
		fw `"    ]"'
		fw `"};"'
		fw, e t 
	}
	if "`htmlname'" !="" di `"点击{browse `htmlname'.html:`htmlname'.html}即可打开结果文件"'
	if "`htmlname'" =="" di `"点击{browse fw_example.html:fw_example.html}即可打开结果文件"'
	if "`c(os)'" == "MacOSX"{
		cap qui drm __MACOSX
	}
	if "`htmlname'" !="" copen `htmlname'.html
	if "`htmlname'" =="" copen fw_example.html
end


